import { Controller, Get, Post, Body, Patch, Param, Delete, Query, Request } from '@nestjs/common';
import { DepartService } from './depart.service';
import { DepartDto, DepartUpdateDto } from './dto/depart.dto';
import { JwtNoVerify } from '../../decorators';
import { ApiOperation, ApiParam, ApiBearerAuth, ApiTags } from '@nestjs/swagger';

@ApiTags('部门模块')
@Controller('depart')
export class DepartController {
  constructor(private readonly _departService: DepartService) {}

  @Get('depart-tree')
  @JwtNoVerify()
  @ApiOperation({ summary: '获取部门树状结构' })
  async getdepartTree(@Query('id') id?: string) {
    return this._departService.getdepartTree(id);
  }

  @Get('depart-list')
  @JwtNoVerify()
  @ApiOperation({ summary: '获取部门列表' })
  async getdepartList(@Request() req) {
    return this._departService.getdepartList(req);
  }

  @Get('depart-info')
  @JwtNoVerify()
  @ApiOperation({ summary: '根据id获取部门信息' })
  async getdepartInfo(@Query('id') id?: string) {
    return this._departService.getdepartInfo(id);
  }

  @Post('add-depart')
  @ApiBearerAuth()
  @ApiOperation({ summary: '新增部门' })
  async adddepart(@Request() req, @Body() DepartDto: DepartDto) {
    return this._departService.adddepart(req, DepartDto);
  }

  @Post('update-depart')
  @ApiBearerAuth()
  @ApiOperation({ summary: '更新部门' })
  async updatedepart(@Request() req, @Body() DepartUpdateDto: DepartUpdateDto) {
    return this._departService.updatedepart(req, DepartUpdateDto);
  }

  @Post('delete-depart')
  @ApiBearerAuth()
  @ApiOperation({ summary: '删除部门' })
  async deletedepart(@Request() req, @Body() body: { ids: string[] }) {
    return this._departService.deletedepart(req, body);
  }
}
